package com.qingzhuge.member.dto.response;

import com.qingzhuge.common.enums.ESexType;
import com.qingzhuge.dto.response.BaseResponsePkLongDto;
import com.qingzhuge.member.enums.EnumThirdOauthType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.OneToMany;
import java.util.Date;
import java.util.List;

/**
 * @author : zero.xiao
 * @description :
 * @date :2018/5/4 0004 下午 15:45
 * @modified :
 */
@ApiModel("A会员用户")
@Getter
@Setter
public class SysMemberResponseDto extends BaseResponsePkLongDto {
    private static final long serialVersionUID = 3350619221481362216L;
    @ApiModelProperty("用户名")
    private String username;
    @ApiModelProperty("昵称")
    private String nickname;
    @ApiModelProperty("邮箱")
    private String email;
    @ApiModelProperty("手机号")
    private String mobile;
    @ApiModelProperty("电话号码")
    private String phone;
    @ApiModelProperty("性别")
    private ESexType sex;
    @ApiModelProperty("地址")
    private String address;
    @ApiModelProperty("头像")
    private SysMemberAvatarResponseDto avatar;
    @ApiModelProperty("注册类型")
    private EnumThirdOauthType registerType;
    @ApiModelProperty("登录类型")
    private EnumThirdOauthType loginType;
    @ApiModelProperty("当前登录ip")
    private String currentLoginHost;
    @ApiModelProperty("上次登录ip")
    private String lastLoginHost;
    @ApiModelProperty("上次登录时间")
    private Date lastLoginTime;
    @ApiModelProperty("当前登录时间")
    private Date currentLoginTime;
    @ApiModelProperty("登录次数")
    private Integer loginCount;
    @ApiModelProperty("登录错误次数")
    private Integer loginErrorCount;
    @ApiModelProperty("第三方应用")
    @OneToMany(mappedBy = "user")
    private List<SysMemberThirdPartyAuthResponseDto> oauth;
    /**第三方应用登录换取token用,不存数据库*/
    @ApiModelProperty("第三方应用登录换取token用")
    private SysMemberThirdPartyAuthResponseDto loginOauth;
    public String getAvatarUrl(){
        if (null != this.avatar){
            return this.avatar.getUrl();
        }else{
            return null;
        }
    }
}
